﻿<metro:Window x:Class="D3StatsClient.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:D3StatsClient.Converters"
        xmlns:metro="http://schemas.codeplex.com/elysium"
        xmlns:params="http://schemas.codeplex.com/elysium/params"
        xmlns:interact="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:behaviors="clr-namespace:D3StatsClient.Behaviours"      
        Title="D3 Item Tracker" MinHeight="420" MinWidth="625" Height="420" Width="720">
    <Window.Resources>
        
        <!-- Converters -->
        <converters:BoolToVisibilityConverter x:Key="InvertedBoolToVisibilityConverter" TrueValue="Collapsed" FalseValue="Visible" />
        <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" TrueValue="Visible" FalseValue="Collapsed" />
        <converters:ItemBackgroundColorConverter x:Key="ItemBackgroundColorConverter" />

        <!-- Styles -->
        <Style x:Key="RowBackgroundColorStyle" TargetType="{x:Type DataGridRow}">
            <Setter Property="Background" Value="{Binding Quality, Converter={StaticResource ItemBackgroundColorConverter}}" />
            <Setter Property="IsHitTestVisible" Value="False" />
        </Style>

    </Window.Resources>

    <StackPanel>
        <DockPanel>
            <StackPanel Orientation="Horizontal">
                <Button Content="New" Command="{Binding NewSessionCommand}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="0,0,5,0" />
                <Button Content="Start" Command="{Binding StartRecordingSessionCommand}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="0,0,5,0" />
                <Button Content="Resume" Command="{Binding ResumeSessionCommand}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="75" Margin="0,0,5,0" />
            </StackPanel>
            <Button Content="Stop" Command="{Binding StopRecordingSessionCommand}" VerticalAlignment="Top" Width="75" />
            <Button HorizontalAlignment="Right" Content="Open Session" Command="{Binding OpenSessionPickerCommand}" VerticalAlignment="Top" Width="auto" Margin="10,0,0,0"/>
            <Button HorizontalAlignment="Right" Content="Settings" Command="{Binding OpenSettingsWindowCommand}" VerticalAlignment="Top" Width="75" />
        </DockPanel>
        
        <!-- Session General Information -->
        <DockPanel>
            <StackPanel DockPanel.Dock="Left" Orientation="Vertical">
                <TextBlock Text="{Binding Status}" />
            </StackPanel>
            <StackPanel>
                <TextBlock FontWeight="Bold" Foreground="#1ba1e2" FontSize="14" Text="{Binding SessionName}" Margin="10,20,0,0"/>
            </StackPanel>
            <StackPanel HorizontalAlignment="Right" DockPanel.Dock="Right" Orientation="Vertical" Margin="0,10,10,0">
                <TextBlock Text="Time played this session" />
                <TextBlock Text="{Binding SessionTime}" />
            </StackPanel>
        </DockPanel>
        
        <!-- Drops Tracker -->
        <DataGrid ItemsSource="{Binding RecordedItems}" 
                  Height="205"
                  CanUserSortColumns="True"
                  AutoGenerateColumns="False"
                  GridLinesVisibility="None"
                  HeadersVisibility="Column"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserReorderColumns="True"
                  Background="{Binding BackgroundColor}"
                  ScrollViewer.VerticalScrollBarVisibility="Auto"
                  ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                  ScrollViewer.CanContentScroll="True" 
                  ScrollViewer.PanningMode="VerticalOnly"
                  ItemContainerStyle="{StaticResource RowBackgroundColorStyle}">
    
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Time"  Binding="{Binding Time}" Width="150" CanUserSort="True" />
                    <DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="200" CanUserSort="True"/>
                    <DataGridTextColumn Header="Quality" Binding="{Binding Quality}" Width="80" CanUserSort="True"/>
                    <DataGridTextColumn Header="Level" Binding="{Binding ItemLevel}" Width="75" CanUserSort="True"/>
                    <DataGridTextColumn Header="Magic Find" Binding="{Binding MagicFind}" Width="110" CanUserSort="True"/>
                    <DataGridTextColumn Header="Looted" Binding="{Binding IsPickedUp}" Width="80" CanUserSort="True"/>
            </DataGrid.Columns>
            
            <interact:Interaction.Behaviors>
                <behaviors:ListViewAutoScrollBehaviour AutoScroll="True" />
            </interact:Interaction.Behaviors>
        </DataGrid>
        
        <!-- Session Stats Area -->
        <StackPanel Margin="6" Orientation="Vertical">
            <DockPanel>
                <StackPanel Orientation="Vertical" HorizontalAlignment="Left">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock ToolTip="The total number of items found so far this session." Text="Total Items Found: " />
                        <TextBlock Text="{Binding Stats.TotalItems}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Server: " />
                        <TextBlock Text="{Binding Server}" Margin="2,2,2,2" />
                    </StackPanel>
                </StackPanel>
                <!--<StackPanel Orientation="Vertical" HorizontalAlignment="Right">
                    <TextBlock ToolTip="Percentage of level 63s" Text="ILevel 63s %"/>
                    <TextBlock Text="{Binding Stats.ILevel63Percentage, StringFormat={}{0:F2}% }" />
                </StackPanel>-->
            </DockPanel>
            <DockPanel>
                <StackPanel>
                    <StackPanel Orientation="Horizontal" >
                        <TextBlock ToolTip="" Text="Rares: " />
                        <TextBlock Text="{Binding Stats.Rares}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <TextBlock  DockPanel.Dock="Top" ToolTip="" Text="Blues: " />
                        <TextBlock  DockPanel.Dock="Bottom" Text="{Binding Stats.Magic}" />
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <TextBlock  DockPanel.Dock="Top" ToolTip="" Text="Legendaries: " />
                        <TextBlock  DockPanel.Dock="Bottom" Text="{Binding Stats.Legendaries}" />
                    </StackPanel>
                </StackPanel>            
                <StackPanel Orientation="Vertical" HorizontalAlignment="Right">
                    <TextBlock ToolTip="Percentage of level 63s" Margin="0,0,10,0" Text="Gold"/>
                    <TextBlock Text="{Binding Stats.Gold }" Margin="0,0,10,0" />
                </StackPanel>
            </DockPanel>
            
        </StackPanel>
        <TextBlock VerticalAlignment="Bottom" Margin="6,0,0,0" TextElement.FontSize="8" Text=""/>
    </StackPanel>
</metro:Window>
